﻿using System.Net.NetworkInformation;
using System.Text;

namespace ThePingMaster
{
    class PingSender : IPingSender
    {
        private readonly Ping _pingSender;
        private readonly PingOptions _options;
        private readonly byte[] _buffer;
        private readonly int _timeout;
        
        public PingSender(int timeout)
        {
            _pingSender = new Ping();
            _options = new PingOptions { DontFragment = true };
            string data = "".PadLeft(32, '*');
            _buffer = Encoding.ASCII.GetBytes(data);
            _timeout = timeout;
        }

        public PingReply Send(string address)
        {
            return _pingSender.Send(address, _timeout, _buffer, _options);
        }
    }
}
